﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : ComponentFactory
* 文 件 名 : ComponentFactory 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/3/5 1:17:47
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
  public static class ComponentFactory
  {
    public static T Create<T>(Entity entity) where T : Component
    {
      T tmp = Game.ObjectPool.FetchObject<T>();
      tmp.Parent = entity;
      Game.EventSystem.Awake(tmp);
      return tmp;
    }

    public static T1 Create<T1, T2>(Entity entity, T2 t2) where T1 : Component
    {
      T1 tmp = Game.ObjectPool.FetchObject<T1>();
      tmp.Parent = entity;
      Game.EventSystem.Awake(tmp, t2);
      return tmp;
    }

    public static T1 Create<T1, T2, T3>(Entity entity, T2 t2, T3 t3) where T1 : Component
    {
      T1 tmp = Game.ObjectPool.FetchObject<T1>();
      tmp.Parent = entity;
      Game.EventSystem.Awake(tmp, t2, t3);
      return tmp;
    }
    public static T1 Create<T1, T2, T3, T4>(Entity entity, T2 t2, T3 t3, T4 t4) where T1 : Component
    {
      T1 tmp = Game.ObjectPool.FetchObject<T1>();
      tmp.Parent = entity;
      Game.EventSystem.Awake(tmp, t2, t3, t4);
      return tmp;
    }
  }
}
